﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SoccerSimulator5000
{
    public class Date
    {
        
        public enum Months
        {
            January = 1,
            February,
            March,
            April,
            May,
            June,
            July,
            August,
            September,
            Oktober,
            November,
            December
        };

        public enum Weeks
        {
            Week1 = 1,
            Week2,
            Week3,
            Week4
        };

        public int year { get; set; }
        public Months month { get; set; }
        public Weeks week { get; set; }
        public int currentIncrement { get; set; }

        public Date()
        {
            currentIncrement = 0;
            year = 2014;
            month = Months.January;
            week = Weeks.Week1;
        }

        public Date( int round )
        {
            currentIncrement = 0;
            year = Game.date.year;
            month = Months.January;
            week = Weeks.Week1;

            int numberOfIncrements = 0;

            numberOfIncrements = Game.schedule.gameWeeks[round];

            for (int i = 0; i < numberOfIncrements; i++)
            {
                this.Increment();
            }


        }

        public Date(int year, Months month, Weeks week)
        {
            this.year = year;
            this.month = month;
            this.week = week;
        }

        public void Increment()
        {
            currentIncrement++;
            week++;
            if (week == Weeks.Week4+1) { week = Weeks.Week1; }
            if (week == Weeks.Week1)
            {
                month++;
                if (month == Months.December + 1) { month = Months.January; }
                if (month == Months.January)
                {
                    year++;
                    currentIncrement = 0;
                }
            }
            

        }

        public void Draw( int x, int y, System.Drawing.Graphics g)
        {
            if( Game.initialized )
                g.DrawString(("Date: " + week + " " + month + " " + year), new System.Drawing.Font(System.Drawing.FontFamily.GenericSansSerif, 12), System.Drawing.Brushes.Black, new System.Drawing.PointF(x, y));
            
        }

        public override string ToString()
        {
            return (week + " " + month + " " + year);
        }

        public override bool Equals(object obj)
        {
            return this == obj;
        }

        public static bool operator==( Date date1, Date date2 )
        {
            if ( (date1.year == date2.year) && (date1.month == date2.month) && (date1.week == date2.week) )
            {
                return true;
            }
            return false;
        }

        public static bool operator !=(Date date1, Date date2)
        {
            return (date1 == date2);
        }
    }
}
